package com.klhappy.houyuan.utils;

import android.os.AsyncTask;

import java.io.File;

public class PicAsynTask extends AsyncTask<Void, Void, Void> {

	private File[] files;
	private File inputFile, newFile;
	private int size, px, index;
	private PicCompressCallback callback;
	
	public PicAsynTask() {
		super();
	}
	
	public PicAsynTask(File[] files, File newFile, int px, int size, int index) {
		super();
		this.files = files;
		this.inputFile = files[index];
		this.newFile = newFile;
		this.size = size;
		this.px = px;
		this.index = index;
	}

	@Override
	protected Void doInBackground(Void... arg0) {
		CompressPictureUtils.transImage(inputFile.getAbsolutePath(), newFile.getAbsolutePath(), 800000, size);
		return null;
	}
	
	@Override
	protected void onPostExecute(Void result) {
		super.onPostExecute(result);
		if (null != callback) {
			callback.dealOk(files, index, newFile);
		}
	}

	public void setPicCompressCallback(PicCompressCallback callback) {
		this.callback = callback;
	}
	
	public interface PicCompressCallback {
		public abstract void dealOk(File[] files, int index, File newFile);
	}

}
